package com.nettcp;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Calendar;

public class TCPServer {

	public static void main(String[] args) throws IOException {
		ServerSocket serverSocket = new ServerSocket(20000);//创建对象
		Socket socket = serverSocket.accept();//调用	ServerSocket对象的accept方法接受数据
	
		InputStream in = socket.getInputStream();//得到的数据流  返回数据流并读取
		byte[] buffer = new byte[1024];//定义1024个字节数组的缓冲区
		int len = in.read(buffer);//将数据读到缓冲区
		System.out.println("服务器端接收到:"+new String(buffer,0,len));//将缓冲区中的数据输出

		socket.close();//关闭socket对象，释放数据
		
	}

}
